home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / jaq / dist / asaca.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  6.9 KB  |  184 lines

  1. /*
  2.  * 
  3.  * Copyright (c) 1988 Regents of the University of California
  4.  * 
  5.  * Permission to use, copy, modify, and distribute this software and its
  6.  * documentation for educational, research, and non-profit purposes and
  7.  * without fee is hereby granted, provided that the above copyright
  8.  * notice appear in all copies and that both that copyright notice and
  9.  * this permission notice appear in supporting documentation, and that
  10.  * the name of the University of California not be used in advertising
  11.  * or publicity pertaining to distribution of the software without
  12.  * specific, written prior permission.  Permission to incorporate this
  13.  * software into commercial products can be obtained from the Campus
  14.  * Software Office, 295 Evans Hall, University of California, Berkeley,
  15.  * Ca., 94720 provided only that the the requestor give the University
  16.  * of California a free licence to any derived software for educational
  17.  * and research purposes.  The University of California makes no
  18.  * representations about the suitability of this software for any
  19.  * purpose.  It is provided "as is" without express or implied warranty.
  20.  * 
  21.  */
  22.  
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <fcntl.h>
  26. #include <limits.h>
  27. #include <termio.h>
  28. #include <errno.h>
  29. #include <stdio.h>
  30. #include <ctype.h>
  31. #include <sys/ioctl.h>
  32.  
  33. /*
  34.  * ASACA (Metrum RSS-600) device driver. Metrum numbers drum bins by
  35.  * drum face designator ('A' - 'L') and bin number (01 - 50) with a
  36.  * maximum of 600 drum bins. Also, there are up to five RSP-2150 tape
  37.  * readers (or, "VLDS"'s) in an RSS-600. We provide a "slot numer"
  38.  * interface to the user and simply number the drum bins as slots 
  39.  * 0 ... 599 and the tape readers as slots 600 ... 604. The mapping,
  40.  * in Metrum RSS-600 terms, is as follows:
  41.  *
  42.  *    Drum face:    Bin number:    VLDS number    Slot number:
  43.  *    *********    **********    ***********    ************
  44.  *      'A'            '01'       N/A             0
  45.  *      'A'            '02'       N/A             1
  46.  *       .              .             .             .
  47.  *       .              .             .             .
  48.  *      'A'            '50'       N/A            49
  49.  *      'B'            '01'       N/A            50
  50.  *       .              .             .             .
  51.  *       .              .             .             .
  52.  *      'B'            '50'       N/A            99
  53.  *      'C'            '00'       N/A           100
  54.  *       .              .             .             .
  55.  *       .              .             .             .
  56.  *      'L'            '50'       N/A           599
  57.  *      N/A            N/A             0           600
  58.  *      N/A            N/A             1           601
  59.  *      N/A            N/A             2           602
  60.  *      N/A            N/A             3           603
  61.  *      N/A            N/A             4           604
  62.  */
  63.  
  64. #define    AS_MAXBIN    599
  65. #define    AS_VLDS0    600
  66. #define    AS_VLDS1    601
  67. #define    AS_VLDS2    602
  68. #define    AS_VLDS3    603
  69. #define    AS_VLDS4    604
  70.  
  71. #define isvlds(x)    ((AS_VLDS0 <= (x)) && ((x) <= AS_VLDS4))
  72. #define isbin(x)    ((0 <= (x)) && ((x) <= AS_MAXBIN))
  73. #define    unittocmd(x)    ('A' + ((x) & 0xff))
  74. #define    unittoface(x)    ('A' + ((x) / 50))
  75. #define    unittobin(x)    (((x) % 50) + 1)
  76. #define    unittovlds(x)    ('1' + ((x) - AS_VLDS0))
  77.  
  78. struct ascmd {
  79.     short    as_bin;            /* normally, bin #0 - #599 */
  80. #define    as_src    as_bin            /* slot to move tape FROM */
  81.     short    as_vlds;        /* normally, VLDS #600 - #604 */
  82. #define    as_dest    as_vlds            /* slot to move tape TO */
  83.     short    as_mode;        /* operating mode */
  84.     char    as_barcode[13];        /* barcode */
  85. #define    as_sense as_barcode
  86.     short    as_error;        /* Error level; see below */
  87. };
  88.  
  89. /*
  90.  * ASACA ioctl's available to applications. The following set of ioctl's
  91.  * correspond, more or less, directly to the actual ASACA commands.
  92.  *
  93.  * NOTE: the driver relies on order of these commands; do not reorder or
  94.  * renumber.
  95.  */
  96. #define    ASIOCSTORE2    _IOWR('z',0, struct ascmd)    /* store w/bar code */
  97. #define    ASIOCLOAD2    _IOWR('z',1, struct ascmd)    /* load w/bar code */
  98.                             /* 'C' not used */
  99. #define    ASIOCLOAD1    _IOWR('z',3, struct ascmd)    /* load w/o bar code */
  100. #define    ASIOCEJECT    _IOR('z',4, struct ascmd)    /* Eject */
  101. #define    ASIOCALRMOFF    _IOW('z',5, struct ascmd)    /* Alarm clear */
  102.                             /* 'G' not used */
  103. #define    ASIOCBCREAD1    _IOWR('z',7, struct ascmd)    /* Bar code read (50) */
  104. #define    ASIOCMANUAL    _IOW('z',8, struct ascmd)    /* Manual enable */
  105. #define    ASIOCDRUMSET    _IOWR('z',9, struct ascmd)    /* Set drum face */
  106. #define    ASIOCBCRS    _IOW('z',10, struct ascmd)    /* Bar code read stop */
  107. #define    ASIOCSIDEIND    _IOW('z',11, struct ascmd)    /* Side door ind. */
  108. #define    ASIOCBCREAD2    _IOWR('z',12, struct ascmd)    /* Bar code read (1)*/
  109. #define    ASIOCINIT    _IO('z',13)            /* Initialize */
  110.                             /* 'O' reserved */
  111. #define    ASIOCMOVE1    _IOWR('z',15, struct ascmd)    /* VLDS - VLDS move */
  112. #define    ASIOCMOVE2    _IOWR('z',16, struct ascmd)    /* bin - bin move*/
  113. #define    ASIOCMOVE3    _IOWR('z',17, struct ascmd)    /* move handler */
  114. #define    ASIOCSENSE    _IOR('z',18, struct ascmd)    /* Door/Carrier sense */
  115. #define    ASIOCINJECT    _IOR('z',19, struct ascmd)    /* Inject */
  116. #define    ASIOCDOORLOCK    _IOW('z',20, struct ascmd)    /* Side door lock */
  117. #define    ASIOCSTORE1    _IOWR('z',21, struct ascmd)    /* store w/o bar code */
  118. #define    ASIOCDETECT    _IOWR('z',22, struct ascmd)    /* Cassette detect */
  119. #define    ASIOCFIPDISP    _IOW('z',23, struct ascmd)    /* FIP display */
  120. #define    ASIOCALRMON    _IOW('z',24, struct ascmd)    /* Alarm on */
  121. #define    ASIOCDOOROPEN    _IO('z',25)            /* Front door open */
  122. /*
  123.  * End of order-specific ioctl's. The following ioctl's give applications a
  124.  * more  "generic" tape and handler "MOVE" interface. "as_src" and "as_dest"
  125.  * must be set to either a drum bin number or a VLDS number for ASIOCMVTAPE,
  126.  * while ASIOCMVHDLR only checks "as_dest". ASIOCMVTAPE_BC does barcode
  127.  * checks on move; no need to mess around with "as_mode"
  128.  */
  129. #define    ASIOCMVTAPE    _IOWR('z',26, struct ascmd)
  130. #define    ASIOCMVTAPE_BC    _IOWR('z',27, struct ascmd)
  131. #define    ASIOCMVHDLR    _IOWR('z',28, struct ascmd)
  132.  
  133.  
  134. /*
  135.  * Error codes
  136.  */
  137. #define    AS_ENOERR    0
  138. #define    AS_EWARN    1
  139. #define    AS_EFATAL    2
  140.  
  141. /*
  142.  * Special tokens
  143.  */
  144. #define    ASHDR        'O'    /* Header char. of ASACA cmds */
  145. #define    ASTERM        '>'    /* Terminator char. of ASACA cmds */
  146. #define    ASALRMALL    '0'    /* turn all alarams on/off */
  147. #define    ASALRM1        '1'    /* turn alarm 1 on/off */
  148. #define    ASALRM2        '2'    /*  "     "   2  "  "  */
  149. #define    ASALRM3        '3'    /*  "     "   3  "  "  */
  150. #define    ASON        'N'    /* "ON" or "ENABLE" */
  151. #define    ASOFF        'F'    /* "OFF" or "DISABLE" */
  152. #define    ASUNLOCK    '0'    /* unlock door */
  153. #define    ASLOCK        '1'    /* lock door */
  154. #define    ASBARCHK    'Y'    /* perform barcode check */
  155. #define    ASNOBARCHK    'N'    /* no barcode chk */
  156.  
  157. #ifdef    DRIVER
  158. /*
  159.  * Termio struct for ASACA serial line. Need to to a TIOCSETA operation on
  160.  * the ASACA serial port prior to operation.
  161.  */
  162. struct termio    asaca_tio =
  163. {
  164.     /* c_iflag  */ IGNBRK,
  165.     /* c_oflag  */ 0,
  166.     /* c_cflag  */ B2400 | CS8 | CREAD | PARENB | PARODD | HUPCL | CLOCAL,
  167.     /* c_lflag  */ 0,
  168.     /* c_line   */ 0,
  169.     /* c_cc     */ {
  170.     /*   VINTR    */    0,
  171.     /*   VQUIT    */    0,
  172.     /*   VERASE   */    0,
  173.     /*   VKILL    */    0,
  174.     /*   VEOF     */    0,
  175.     /*   VEOL     */    0,
  176.     /*   VEOL2    */    0,
  177.     /*   VSWITCH  */    0,
  178.     /*   VMIN     */    0,
  179.     /*   VTIME    */  100,      /* wait 10s for a character */ }
  180. };
  181. #else    DRIVER
  182. extern struct termio asaca_tio;
  183. #endif    DRIVER
  184.